<%@ page contentType="text/html; charset=UTF-8" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>验证码</title> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <script src="${pageContext.request.contextPath}/static/js/KeysManager/index.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/KeysManager/VerifyCode.css?v=3">
    <link href="${pageContext.request.contextPath}/static/plugins/layer_mobile/need/layer.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/static/js/jquery-1.11.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/yahlj-app.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/layer_mobile/layer.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery.qrcode.min.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/js/KeysManager/VerifyCode.js?date=0119.1"></script>
    
</head>
<body>
<input type="hidden" id="tel" value="${tel}">
<input type="hidden" id="i" value="${i}">
<input type="hidden" id="c" value="${c}">
<input type="hidden" id="u" value="${u}">

<div class="box">
    <div class="item">
    	验证码
        <input onchange="change_btn()" type="text" class="verify-code" id='code' placeholder="请输入验证码" maxlength="6"/>
        <button class="get-verify" id="send">获取验证码</button>
    </div>
    <p class="label">尊敬的用户:您好,您的验证码发送至原主人绑定的手机${tel_}</p>
    <button id="ok" onclick="yes()">确定</button>
</div>


</body>
</html>

<script>
$('#code').bind('input propertychange', function() {
	var html=$('.verify-code').val();
	if(html.length==5 || html!=''){
		$('#ok').css('background','#cbab7f');
		$('#ok').css('color','#fff');
	}else{
		$('#ok').css('background','#dbdbdb');
		$('#ok').css('color','#a8a8a8');
	}
}); 
/* function change_btn(){
	alert(111)
	var html=$('.verify-code').html();
	if(html!=''){
		alert(html);
		$('#ok').css('background','#f00');
	}
} */






;(function(window, undefined){
	
	
	var str = "${url}";
	var weight = $("#qr_code").width();
	$('#qr_code').qrcode({
		width: weight,
		height:weight,
		text: str,
	});
	
	
})(window);

function showMsg(content){
	layer.open({
	    content:content,
	    time:2
	});
}


function yes(){
	try{
		var tel=$("#tel").val();
		var i=$("#i").val();
		var c=$("#c").val();
		var u=$("#u").val();
		var code=$("#code").val();
		if(!code){
			showMsg('请输入验证码');
			return;
		}
		$.ajax({   
		    url:'<%=request.getContextPath()%>/admin/tlocks_checkTransferCode.action',   
		    type:'post',
		    data:'tel='+tel+"&i="+i+"&c="+c+"&u="+u+"&telCode="+code,   
		    async : true, //默认为true 异步   
		    dataType:'json',
		    error: function(XMLHttpRequest, textStatus, errorThrown) {
		    },  
		    success:function(result){   
		    	var data = result.data;
		       if(result.code=='1'){
		    	   if(result.login_status=='1'){
		    		   window.location.href="<%=request.getContextPath()%>/register/registerLockApp.action?pid="+result.pid+"&checkcode="+result.checkcode+"&type=2";   
		    	   }else{
		    		   window.location.href="<%=request.getContextPath()%>/admin/tlocks_addLockApp.action?pid="+result.pid+"&checkcode="+result.checkcode+"&type=2";
		    	   }
		    	  
		       }else{
		    	   showMsg(result.msg);    	  
		       }
		    }
		});
	}catch (e) {
		alert(e.message)
	}
	
	
}
</script>